package com.liuhx.mapper;

import com.liuhx.entity.BrandEntity;
import com.liuhx.mapper.sql.BrandSql;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by liuhx on 2017/6/21.
 */
public interface BrandMapper {
    @Select("SELECT * FROM brand_info")
    @Results({
            @Result(property = "brandId" ,column = "brandId", javaType = Integer.class),
            @Result(property = "brandName",  column = "brandName", javaType = String.class),
            @Result(property = "brandUrl", column = "brandUrl",javaType = String.class)
    })
    List<BrandEntity> getAll();

    @InsertProvider(type = BrandSql.class,method = "insertBrands")
    @Options(useGeneratedKeys = true, keyProperty = "brandId")
    void insertBrands(List<BrandEntity> brandEntityList);

    @Select("select brandName,brandUrl from brand_info")
    @Results(
            {
                    @Result(property = "brandName",column = "brandName"),
                    @Result(property = "brandUrl",column = "brandUrl")
            }
    )
    List<BrandEntity> findAllBrands();
}
